package cn.bearspark.api.controller.func;

import cn.bearspark.api.service.func.LikeService;
import cn.bearspark.api.vo.func.like.CommentReqVO;
import cn.bearspark.api.vo.func.like.HappeningReqVO;
import cn.bearspark.framework.web.starter.vo.ResponseVO;
import jakarta.validation.Valid;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 点赞模块
 *
 * @author f
 */
@Validated
@RestController
@RequestMapping("/like")
public class LikeController {

    private final LikeService likeService;

    public LikeController(LikeService likeService) {
        this.likeService = likeService;
    }

    /**
     * 动态点赞/取消点赞
     *
     * @param happeningReqVO 动态点赞/取消点赞的请求对象
     * @return 响应对象
     */
    @PostMapping("/happening")
    public ResponseVO<Object> likeHappening(@Valid @RequestBody HappeningReqVO happeningReqVO) {
        likeService.likeHappening(happeningReqVO);
        return ResponseVO.success();
    }

    /**
     * 评论点赞/取消点赞
     *
     * @param commentReqVO 评论点赞/取消点赞的请求对象
     * @return 响应对象
     */
    @PostMapping("/comment")
    public ResponseVO<Object> likeComment(@Valid @RequestBody CommentReqVO commentReqVO) {
        likeService.likeComment(commentReqVO);
        return ResponseVO.success();
    }

}
